#！/bin/bash


logfile=/var/log/web_daily_backup.log
dump_dir=/home/web_robox_data 
date_time=`date "+%m_%d"`
dump_file=$dump_dir/web_data_${date_time}.sql 



if [ ! -f $dump_dir ];then
	mkdir -p $dump_dir
fi
cd $dump_dir

mysqldump -h 127.0.0.1 -u root  robox_web >web_data_${date_time}.sql  2>>$logfile

if [ $? -eq 0 ];then
	echo `date "+%Y-%m-%d %H:%m:%S"`:"  mysql_dump success   ! " >>$logfile
fi




if [ `du -a $logfile |egrep -o "[0-9]+"` -ge 1073741824 ];then
	cd /var/log/
	tar cvf web_daily_backup_log_${date_time}.tar.gz web_daily_backup.log
	rm -rf web_daily_backup.log
	cd -
fi